#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

//链接：https://www.acwing.com/problem/content/3772/

int main(){
    int t,n,d;
    cin >> t;
    while (t--){
        cin >> n >> d;
        int res ;
        cin >> res;
        for (int i = 1; i < n; i++){
            int temp ;
            cin >> temp;
            int x = min(temp,d / i);
            res += x;
            d -= x * i;
        }
        cout << res << endl;
    }
    return 0;
}